<?php
/**
 * Extends the user class to add the OpenIdUrl property.
 *
 * @package Extensions
 * @version @@VERSION@@
 * @subpackage @@EXTENSIONNAME@@
 * @copyright Damien Lebrun 2007
 * @author Damien Lebrun
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GPLv2
 */

if (!defined('IN_VANILLA')) exit();
include_once($Configuration['LIBRARY_PATH'] . 'People/People.Class.User.php');

/**
 * Extends the user class to add the OpenIdUrl property.
 * @package Extension
 * @subpackage @@EXTENSIONNAME@@
 */
Class OpenID_User extends User {
	var $OpenIdUrls = array();
	var $UseOpenId = 0;

	/**
	 * Reset properties
	 *
	 * @return void
	 */
	function Clear() {
		parent::Clear();
		$this->OpenIdUrls = array();
		$this->UseOpenId = 0;
	}

	/**
	 * Format properties to prevent sql injection
	 * @return void
	 */
	function FormatPropertiesForDatabaseInput() {
		parent::FormatPropertiesForDatabaseInput();
		$this->UseOpenId = ForceInt($this->UseOpenId, 0);
		foreach ($this->OpenIdUrls as $key => $url) {
			$this->OpenIdUrls[$key] = FormatStringForDatabaseInput($url, 1);
		}
	}

	/**
	 * Format properties for display
	 * @return void
	 */
	function FormatPropertiesForDisplay() {
		parent::FormatPropertiesForDisplay();
		$this->UseOpenId = ForceInt($this->UseOpenId, 0);
		foreach ($this->OpenIdUrls as $key => $url) {
			$this->OpenIdUrls[$key] = FormatStringForDisplay($url, 1);
		}
	}

	/**
	 * Get the property from DB
	 * @param array $DataSet
	 * @return void
	 */
	function GetPropertiesFromDataSet($DataSet) {
		parent::GetPropertiesFromDataSet($DataSet);
		$this->UseOpenId = ForceInt(@$DataSet['UseOpenId'], 0);
		if (in_array('OpenIdUrl', $DataSet)) {
			$this->OpenIdUrls[] = ForceString(@$DataSet['OpenIdUrl'], '');
		}
	}

	/**
	 * Get the property from a form and format them.
	 * @return void
	 */
	function GetPropertiesFromForm() {
		parent::GetPropertiesFromForm();
		$this->OpenIdUrls[] = ForceIncomingString('OpenIdUrl', '');
	}
}
